package com.study.lagou.edu;

import java.util.HashMap;
import java.util.Map;

public class ArrayElementUnRepeat {

    private static String arrayElementUnRepeat(int[] numbers) {
        if (numbers.length == 0) {
            return "YES";
        }

        Map<Integer, Integer> numMap = new HashMap<>();
        for (int i = 0; i < numbers.length; i++) {
            if (numMap.containsKey(numbers[i])) {
                return "NO";
            } else {
                numMap.put(numbers[i], 1);
            }
        }

        return "YES";
    }

    public static void main(String[] args) {
        int[] numbers = {1, 5, 6, 7, 2, 4, 9, 3};
        System.out.println(arrayElementUnRepeat(numbers));

        int[] numbers2 = {1, 5, 6, 7, 2, 4, 9, 3, 2, 4, 7, 2, 8, 2, 9, 2, 7};
        System.out.println(arrayElementUnRepeat(numbers2));
    }
}
